// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: AdminProModifyAction.java

package com.market.web.action;

import org.apache.struts.action.ActionForward;
import org.springframework.beans.BeanUtils;

import com.market.bean.Beer;
import com.market.bean.Product;
import com.market.bean.Rice;
import com.market.bean.Safety;
import com.market.web.form.BeerForm;
import com.market.web.form.RiceForm;
import com.market.web.form.SafetyForm;

// Referenced classes of package com.market.web.action:
// AdminProductAction

public class AdminProModifyAction extends AdminProductAction
{

    public AdminProModifyAction()
    {
    }

    public String execute() throws Exception
    {
        long id = getLong("id");
        Product pro = getProductService().findById(id);
        if (pro == null)
        {
            /*ActionMessages error = new ActionMessages();
            error.add("org.apache.struts.action.GLOBAL_MESSAGE", new ActionMessage(
                    "\u627E\u4E0D\u5230\u76F8\u5E94\u7684\u5546\u54C1.", false));
            saveErrors(request, error);*/
           // return mapping.getInputForward();
            return INPUT;
        }
        else
        {
            return processForward(pro);
        }
    }

    private String processForward(Product pro)
    {
        String category = pro.getCategory();
        String result = "";
        ActionForward forward = null;
        if ("rice".equals(category))
        {
            Rice l = (Rice)getProductService().findById(com.market.bean.Rice.class, pro.getId());
            RiceForm lf = new RiceForm();
            BeanUtils.copyProperties(l, lf);
            getRequest().setAttribute("riceForm", lf);
            //forward = new ActionForward("/adminProAdd.do?category=" + category);
            result="/adminProAdd.do?category=rice" ;
        }
        else if ("beer".equals(category))
        {
            Beer l = (Beer)getProductService().findById(com.market.bean.Beer.class, pro.getId());
            BeerForm lf = new BeerForm();
            BeanUtils.copyProperties(l, lf);
            getRequest().setAttribute("beerForm", lf);
            //forward = new ActionForward("/adminProAdd.do?category=" + pro.getCategory());
            result="/adminProAdd.do?category=beer" ;
        }
      /*  else if ("bowb".equals(category))
        {
            Bowb el = (Bowb)getProductService().findById(com.market.bean.Bowb.class, pro.getId());
            BowbForm elf = new BowbForm();
            BeanUtils.copyProperties(el, elf);
            request.setAttribute("bowbForm", elf);
            forward = new ActionForward("/adminProAdd.do?category=" + pro.getCategory());
        }
        else if ("arrow".equals(category))
        {
            Arrow ki = (Arrow)getProductService().findById(com.market.bean.Arrow.class, pro.getId());
            ArrowForm kf = new ArrowForm();
            BeanUtils.copyProperties(ki, kf);
            request.setAttribute("arrowForm", kf);
            forward = new ActionForward("/adminProAdd.do?category=" + pro.getCategory());
        }
        else if ("collimator".equals(category))
        {
            Collimator pm = (Collimator)getProductService().findById(com.market.bean.Collimator.class, pro.getId());
            CollForm pmf = new CollForm();
            BeanUtils.copyProperties(pm, pmf);
            request.setAttribute("collForm", pmf);
            forward = new ActionForward("/adminProAdd.do?category=" + pro.getCategory());
        }*/
        else if ("safety".equals(category))
        {
            Safety pmb = (Safety)getProductService().findById(com.market.bean.Safety.class, pro.getId());
            SafetyForm pmbf = new SafetyForm();
            BeanUtils.copyProperties(pmb, pmbf);
            getRequest().setAttribute("safetyForm", pmbf);
            //forward = new ActionForward("/adminProAdd.do?category=" + pro.getCategory());
            result="/adminProAdd.do?category=safety" ;
        }
        else
        {
            //Bowa hw = (Bowa)getProductService().findById(com.market.bean.Bowa.class, pro.getId());
            RiceForm hwf = new RiceForm();
            //BeanUtils.copyProperties(hw, hwf);
            getRequest().setAttribute("riceForm", hwf);
            //forward = new ActionForward("/adminProAdd.do?category=rice");
            result="/adminProAdd.do?category=rice" ;
        }
        return result;
    }
}
